package base;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

public class NibbleArrayTest {
	@Test
	public void getDynamicConstructorBySize() {
		int dimSize = 16;
		int size = dimSize * dimSize * dimSize;
		NibbleArray t = new NibbleArray(size);
		for (int x = 0; x < dimSize; x++) {
			for (int y = 0; y < dimSize; y++) {
				for (int z = 0; z < dimSize; z++) {
					t.set(x, y, z, x + y + z);
				}
			}
		}
		assertEquals(t.getNibbleSize(),size);
		assertEquals(t.get(1, 1, 1), 3);
		assertEquals(t.get(15, 15, 15), 13);
	}
	
	@Test
	public void getDynamicConstructorByData() {
		byte[] data= NibbleArray.hexStringToByteArray("0102");
		NibbleArray t = new NibbleArray(data);
		assertEquals(t.getNibbleSize(),4);
		assertEquals(t.get(0,0, 0), 1);
		assertEquals(t.get(2, 0, 0), 2);
		assertEquals(t.get(3, 0, 0), 0);
	}
}
